'use client';

import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { Button } from '../ui/button';

export default function ErrorComp({
  message,
  backPath,
}: {
  message?: string;
  backPath?: string;
}) {
  const { refresh } = useRouter();
  return (
    <div className="h-screen flex flex-col gap-5 items-center justify-center">
      <h2>{message ?? '出错了'}</h2>
      <div className="flex gap-5">
        <Link href={backPath ?? '/'}>
          <Button>{backPath ? '返回' : '回到首页'}</Button>
        </Link>
        <Button onClick={() => refresh()}>重试</Button>
      </div>
    </div>
  );
}
